package com.yida.system.controller;

import java.util.List;

import com.yida.common.core.web.controller.BaseController;
import com.yida.common.core.web.domain.AjaxResult;
import com.yida.common.core.web.page.TableDataInfo;
import com.yida.common.log.annotation.Log;
import com.yida.common.log.enums.BusinessType;
import com.yida.common.security.annotation.RequiresPermissions;
import com.yida.system.domain.request.SysBlackConfigEditRequest;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.yida.system.api.domain.SysBlackConfig;
import com.yida.system.service.ISysBlackConfigService;


/**
 * 系统黑名单配置Controller
 * 
 * @author wws
 * @date 2023-03-22
 */
@RestController
@RequestMapping("/system/config")
@Api(tags = "系统黑名单配置")
public class SysBlackConfigController extends BaseController
{
    @Autowired
    private ISysBlackConfigService sysBlackConfigService;

    /**
     * 查询系统黑名单配置列表
     */
    @RequiresPermissions("system:black:config:list")
    @GetMapping("/list")
    @ApiOperation("分页查询")
    public TableDataInfo list(SysBlackConfig sysBlackConfig)
    {
        startPage();
        List<SysBlackConfig> list = sysBlackConfigService.selectSysBlackConfigList(sysBlackConfig);
        return getDataTable(list);
    }

    /**
     * 获取系统黑名单配置详细信息
     */
    @RequiresPermissions("system:black:config:query")
    @GetMapping(value = "/{id}")
    @ApiOperation(value = "详情",response = SysBlackConfig.class)
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(sysBlackConfigService.selectSysBlackConfigById(id));
    }


    /**
     * 修改系统黑名单配置
     */
    @RequiresPermissions("system:black:config:edit")
    @Log(title = "系统黑名单配置", businessType = BusinessType.UPDATE)
    @PutMapping
    @ApiOperation(value = "修改系统黑名单配置")
    public AjaxResult edit(@RequestBody @Validated SysBlackConfigEditRequest editRequest)
    {
        return toAjax(sysBlackConfigService.updateSysBlackConfig(editRequest));
    }

}
